﻿using System;
using System.Collections;
using System.Collections.Generic;
//using System.Linq;

namespace WindowsAPI.Windows
{
    public partial class Window
    {
        [Serializable]
        public class WindowsPool : MarshalByRefObject, IEnumerable<Window>
        {
            internal WindowsPool() { }

            #region Implementation of IEnumerable

            public IEnumerator<Window> GetEnumerator()
            {    
                var lv_WindowsList = FindWindow(w => true);
                return new WindowsList(lv_WindowsList).GetEnumerator();
            }

            IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }

            #endregion
        }

        private static readonly WindowsPool sf_Pool = new WindowsPool();

        public static WindowsPool Pool { get { return sf_Pool; } }
    }



}